#!/usr/bin/python3
# -*- coding:utf-8 -*-
# __author__ == taoyulong2018@gmail.com
# __time__ == 2023/5/31 10:45
# ===========================================
#
# ===========================================
import tkinter as tk
import pygame
from page99.log_utils import *

class LoginGUI(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.create_widgets(1,"N")

    def create_widgets(self,p = None, p2=None):
        logger.info("测试info")
        logger.error("error")
        logger.warning("warning")
        logger.debug("debug")

        self.username_label = tk.Label(self, text="Username:")
        self.username_label.pack(side="top")
        self.username_entry = tk.Entry(self)
        self.username_entry.pack(side="top")
        self.password_label = tk.Label(self, text="Password:")
        self.password_label.pack(side="top")
        self.password_entry = tk.Entry(self, show="*")
        self.password_entry.pack(side="top")
        self.login_button = tk.Button(self, text="Login", command=self.login_function)
        self.login_button.pack(side="top")

    def login_function(self):

        username = self.username_entry.get()
        password = self.password_entry.get()
        pygame.init()
        screen = pygame.display.set_mode((500, 500))
        background = pygame.image.load("page99/123.png").convert_alpha()
        screen.blit(background, (0, 0))
        pygame.display.set_caption("Login")
        pygame.display.set_mode((500, 500))
        clock = pygame.time.Clock()
        while True:
            clock.tick(15)
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    return
            username_rect = pygame.Rect(250, 100, 200, 200)
            password_rect = pygame.Rect(375, 100, 200, 200)
            screen.blit(background, (0, 0))
            screen.blit(username_rect, username_rect)
            screen.blit(password_rect, password_rect)
            pygame.display.update()

root = tk.Tk()
login_gui = LoginGUI(root)
login_gui.pack()

root.mainloop()
